package come.example.pagetransformer.fragment

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import come.example.pagetransformer.R
import kotlinx.android.synthetic.main.layout_tt_fragment.*

class TtFragment : Fragment() {

    private var mRootView: View? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        mRootView = inflater.inflate(R.layout.layout_tt_fragment, null)
        return mRootView
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        iniView()
    }

    private fun iniView() {
        arguments?.let {
            tvText.text = it.getString("text")
        }
    }

    companion object {
        fun getInstance(bundle: Bundle?): TtFragment {
            val fragment = TtFragment()
            if (bundle != null) {
                fragment.arguments = bundle
            }
            return fragment
        }
    }
}
